import React, { Component } from 'react'
import { withRouter } from 'react-router-dom'
import Loadable from 'react-loadable'
import { connect } from 'react-redux'
import RenderRoute from './RenderRoute'

class RouteItem extends Component {
    constructor(props) {
        super(props)
    }
    componentWillMount() {
        // let { history: { replace }, authorization, location } = this.props
        // if (authorization) replace('./login')
        // if (location.pathname === '/') replace('./asd')
        // console.log('路由跳转前的拦截', this.props)
    }
    render() {
        let { component, children = [] ,path} = this.props
        const LoadableComponent = Loadable({
            loader: () => import(`@/${component}`),
            loading: () => (
                <span>正在加载</span>
            )
        })
        return (
            <div style={{height:"100%"}}>
                <LoadableComponent {...this.props} >
                    {RenderRoute(children,path)}
                </LoadableComponent>
            </div>
        )
    }
}

export default RouteItem